/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  						 area_effect_point_set.h

	$Header:  $

	$NoKeywords: $

 ************************************************************************/

#if !defined( AREA_EFFECT_POINT_SET_H_INCLUDED )
#define AREA_EFFECT_POINT_SET_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <set>
#include "area_effect_point.h"
#include "area_effect_point_ptr.h"

// Predicate for sorting t_area_effect_point's in a set.
// Don't actually care about the order, just want a
// uniqueness test. The set should be unique on the "affected list"
class t_area_effect_set_predicate
{
	public:
		bool operator()(const t_area_effect_point_ptr &ptr1, const t_area_effect_point_ptr &ptr2) const;
};

inline
bool t_area_effect_set_predicate::operator()(const t_area_effect_point_ptr &ptr1, const t_area_effect_point_ptr &ptr2) const
{
	if (ptr1->get_range_factor() != ptr1->get_range_factor())
	{
		if (ptr1->get_range_factor() < ptr1->get_range_factor())
			return true;
		else
			return false;
	}

	return ptr1->get_affected_list() < ptr2->get_affected_list(); // Yes, there actually is an operator<(std::set<>, std::set) in <set>
}

typedef std::set<t_area_effect_point_ptr, t_area_effect_set_predicate> t_area_effect_point_set;

#endif